<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>综合人气榜</title>
		<link href="css/text.css" rel="stylesheet" type="text/css" />
		<style type="text/css">	
			.fixedBox{
				border: 0px solid #555555;				
				white-space: nowrap;	
				top:"0px"!important;
				height: 100%!important;
			}
			.fixedBox::-webkit-scrollbar {
				width: 0px;     
				height: 0px;				
			}
			.res
			{
				color: Red;
			}
			.result{
				background: Yellow;
			}
			table{
			width:600px; 
			border-collapse:collapse; 
			text-align:center;
			}

			thead th {
				position: sticky;      /* 粘性定位 */
				top: 0;                /* 固定在容器顶部 */
				background: #000000;   /* 背景色覆盖内容 */
				z-index: 1;            /* 确保层级高于内容 */
				height: 20px; 		
			} 

			td,th{border:1px solid #696969}			
		</style>
	</head>
	<body>
		<div id="towrite1" class="fixedBox" style="display:none;"></div>
		<div id="towrite" class="fixedBox" style="display:none;"></div>
		
		<script type="text/javascript" src="js/json2html.js"></script>
		<script type="text/javascript" src="js/jquery.min.js"></script>
		<script>
		    var daochu_codes = [];	
			var bkcolor = $("body").css("backgroundColor")
				window.onload = function() {
				start();			
				changeStyle();
			}
						
			function time_range(beginTime, endTime) {
				var strb = beginTime.split(":");
				if (strb.length != 2) {
					return false;
				}

				var stre = endTime.split(":");
				if (stre.length != 2) {
					return false;
				}

				var b = new Date();
				var e = new Date();
				var n = new Date();

				b.setHours(strb[0]);
				b.setMinutes(strb[1]);
				e.setHours(stre[0]);
				e.setMinutes(stre[1]);

				if (n.getTime() - b.getTime() > 0 && n.getTime() - e.getTime() < 0) {							
					start();					
					console.log(true)　　　　　　
					return true;				
				} else {
					console.log(false)
				    return false;     
				}
			}　　　
   　　　
			$(function() {
				setInterval(function() {
					time_range("9:00","15:15")						
				},
				60000);
			})
						
			function changeStyle() {
				var obj = document.getElementById("towrite");
				obj.style.display= "block";
				obj.style.top= "30px"; 
				obj.style.left= "0px"; 				
				obj.style.width= "710px";	
				obj.style.height= "100%";		
				obj.style.fontSize="12px";			
				obj.style.border="0px solid #000000";	  		
				
				var obj1 = document.getElementById("towrite1");
				obj1.style.display= "block";
				obj1.style.left= "0px"; 				
				obj1.style.width= "710px";	
				obj1.style.height= "100%";		
				obj1.style.fontSize="12px";			
				obj1.style.border="0px solid #000000";	  
			}	
						
			Date.prototype.Format = function (fmt) {
				var o = {
				"M+": this.getMonth() + 1, //月份
				"d+": this.getDate(), //日
				"h+": this.getHours(), //小时
				"m+": this.getMinutes(), //分
				"s+": this.getSeconds(), //秒
				"q+": Math.floor((this.getMonth() + 3) / 3), //季度
				"S": this.getMilliseconds() //毫秒
				};
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
				for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
				return fmt;
			};
			
			function getLocalTime(nS) {			          
			return new Date(parseInt(nS) * 1000).Format("hh:mm:ss")}						
			
			function keepTwoDecimal(num) {  
               var result = parseFloat(num);  
               if (isNaN(result)) {  
                   //alert('传递参数错误，请检查！');  
                   return false;  
               }  
               result = Math.round(num * 100) / 100;  
               return result;  
			};	
			
			function NumberTransform(num) { 
				var result = num;
				if(Math.abs(num) > 100000000){
					result = num / 100000000;
					result = result.toFixed(2) + "亿";
				}else if(Math.abs(num) > 10000){
					result = num/10000;
					result = result.toFixed(0) + "万";
				}				   
				return result;  
			}
			
			var trid = "";
			function changeCss(obj,hid,id){						
				var tlist = document.getElementById(id).getElementsByTagName("tr");					
				for(var i = 0; i < tlist.length; i++){														
					tlist[i].style.backgroundColor = bkcolor; 					
				}
				trid = hid;
				var tr = document.getElementById(hid);				
				tr.style.backgroundColor = "#483D8B";						
			}
			
			function hover(){  //鼠标经过
				var rows = document.getElementsByTagName('tr');
				for(var i=0;i<rows.length;i++){
					rows[i].onmouseover=function(){						
						if(this.id != ""){  //过滤表头
							this.style.background="#800000";
						}
					}
					rows[i].onmouseout=function(){
						if(this.id != ""){  //过滤表头
							if(this.id != trid){  //过滤选中行
								this.style.background=bkcolor;
							}else{
								this.style.background="#483D8B";
							}
						}						
					}					
				}
			}	
			
			var arr = [];
			var arr1 = [];
			var arr2 = [];
			function start() {	  
				getData();  							
				var url = "https://emappdata.eastmoney.com/stockrank/getAllCurrentList"; 	                			
				var dms = "";
				var array = {"appId":"appId01","globalId":"786e4c21-70dc-435a-93bb-38","pageNo":1,"pageSize":100}
				var res = [];
				$.ajax({
					type: "post",
					url: url,
					data : JSON.stringify({"appId":"appId01","globalId":"786e4c21-70dc-435a-93bb-38","pageNo":1,"pageSize":100}),
					contentType : "application/json",
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));							
						res = data.data;
					}
				});	
				for (var i = 0; i < res.length; i++){
					dms += res[i]["sc"].replace("SH","1.").replace("SZ","0.") + ",";
				}				
				dms = dms.substring(0,dms.length - 1);
				
				var url1 = "https://push2.eastmoney.com/api/qt/ulist.np/get?fltt=2&np=3&ut=a79f54e3d4c8d44e494efb8f748db291&invt=2&secids=" + dms + "&fields=f2,f3,f12,f14"; 	                							
				var res1 = [];
				$.ajax({
					type: "get",
					url: url1,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));																
						res1 = data;										
					}
				});
				
				//开盘啦人气榜
				var url2 = "https://apphq.longhuvip.com/w1/api/index.php?Order=1&a=GetHotPHB&st=60&apiv=w21&Type=1&c=StockBidYiDong&PhoneOSNew=1"; 				
				var res2 = [];
				//var res21 = [];
				$.ajax({
					type: "get",
					url: url2,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));																
						for (var i = 0; i < data.List.length; i++){
							var aa = data.List[i];
							res2.push({"code":aa[0],"name":aa[1],"ranking":aa[4],"bh":aa[3],"zf":aa[2]});
						}
						//document.write(ss);	
						//document.write(JSON.stringify(res2));
					}
				});
				
				//同花顺热榜
				var url3 = "https://eq.10jqka.com.cn/open/api/hot_list/v1/hot_stock/a/hour/data.txt";
				var res3 = [];
				$.ajax({
					type: "get",
					url: url3,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {														
						//  for (var i = 0; i < data.data.stock_list.length; i++){ 
						// 	 var c = $.extend({}, data.data[i], {"ranking":(i + 1)});  
						// 	 res3.push(c); 
						//  } 
						res3 = data.data.stock_list;
						//document.write(JSON.stringify(res3));
					}
				});
				//爱股票热榜
				var url5 = "https://www.aigupiao.com/Quote/get_hot_stock_list?number=100"; 
				var res5 = [];
				$.ajax({
					type: "get",
					url: url5,
					dataType: "json",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						//document.write(JSON.stringify(data));																
					for (var i = 0; i < data.data.length; i++){ 
								var c = $.extend({}, data.data[i], {"ranking":(i + 1)}); 
								res5.push(c); 
	
						}
						//document.write(JSON.stringify(res3));
					}
				});

				//东财个股资金流
				var url4 = "http://push2.eastmoney.com/api/qt/clist/get?cb=jQuery112304741865099328959_1633581130706&fid=f62&po=1&pz=6000&pn=1&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m:0+t:6+f:!2,m:0+t:13+f:!2,m:0+t:80+f:!2,m:1+t:2+f:!2,m:1+t:23+f:!2,m:0+t:7+f:!2,m:1+t:3+f:!2&fields=f12,f14,f2,f3,f62,f184,f66,f69"; 	                							
				//var data4 = "";
				var res4 = [];
				$.ajax({
					type: "get",
					url: url4,
					dataType: "text",
					async : false,
					cache:false,
					timeout:3000,					
					success: function(data) {
						//alert(JSON.stringify(data))						
						var data4 = data.replace(/ /g,"")
						data4 = data4.match(/,"diff":(\S*)\}\}\);/)[1];
						//document.write(data4);	
						//data4 = data;	
						res4 =  JSON.parse(data4);
					}
				});						
				//document.write(JSON.stringify(res4));
				
				var res = [];
				for (var i = 0; i < res1.data.diff.length; i++){   //以东财为基准
					var code = res1.data.diff[i]["f12"];						
					var name = res1.data.diff[i]["f14"];
					var xianjia = res1.data.diff[i]["f2"];
					var zf = res1.data.diff[i]["f3"];
					//alert(code)
					
					var pm1 = "1000";  //人气榜					
					var a2 = res2.findIndex((v) => {  //(findIndex)判断数组有无指定对象   
						return v.code ===  code;
					});
					if(a2 > -1){
						var arrfind = res2.find(function (item) {   //取指定值所在对象数组
							return item.code == code
						});
						pm1 = arrfind.ranking; 
						//alert(JSON.stringify(arrfind))	
						//alert(pm1)
					}
					
					var pm2 = "1000";  //同花顺热榜					
					var a3 = res3.findIndex((v) => {   
						return v.code ===  code;
					});
					if(a3 > -1){
						var arrfind = res3.find(function (item) {
							return item.code == code
						});						
						pm2 = arrfind.order; 
					}
					var pm3 = "1000";  //爱股票					
					var a5 = res5.findIndex((v) => {   
						return v.code.replace(/(sz)|(sh)|(bj)/g,"") ===  code;
					});
					if(a5 > -1){
						var arrfind = res5.find(function (item) {
							return item.code.replace(/(sz)|(sh)|(bj)/g,"") == code
						});						
						pm3 = arrfind.ranking; 
					}
					
					
					var zlje = "null";
					var zljzb = "null";	
					var cddje = "null";
					var cddjzb = "null";					
					var a4 = res4.findIndex((v) => {   //东财资金
						return v.f12 ===  code;
					});
					if(a4 > -1){
						var arrfind = res4.find(function (item) {
							return item.f12 == code
						});
						zlje = arrfind.f62; 
						zljzb = arrfind.f184;	
						cddje = arrfind.f66; 
						cddjzb = arrfind.f69;						
					}					
					res.push({"code":code,"name":name,"xianjia":xianjia,"zf":zf,"dcpm":i + 1,"rqbpm":pm1,"thspm":pm2,"rmgppm":pm3,"zlje":zlje,"zljzb":zljzb,"cddje":cddje,"cddjzb":cddjzb})					
				}
				//document.write(JSON.stringify(res));	
				
				for (var i = 0; i < res2.length; i++){	//以开盘啦人气榜为基准				
					var code = res2[i]["code"];
					var a1 = res.findIndex((v) => { 
						return v.code ===  code;
					});
					if(a1 == -1){
						var name = res2[i]["name"];
						var pm1 = res2[i]["ranking"];
						var zf = res2[i]["zf"];
						var dcpm = "1000";					
						var pm2 = "1000";	
						
						var pm2 = "1000";  //同花顺热榜					
						var a3 = res3.findIndex((v) => {   
							return v.code ===  code;
						});
						if(a3 > -1){
							var arrfind = res3.find(function (item) {
								return item.code == code
							});						
							pm2 = arrfind.order; 
						}

						var pm3 = "1000";  //爱股票					
						var a5 = res5.findIndex((v) => {   
							return v.code.replace(/(sz)|(sh)|(bj)/g,"") ===  code;
						});
						if(a5 > -1){
							var arrfind = res5.find(function (item) {
								return item.code.replace(/(sz)|(sh)|(bj)/g,"") == code
							});						
							pm3 = arrfind.ranking; 
						}
					
						var zlje = "null";
						var zljzb = "null";	
						var cddje = "null";
						var cddjzb = "null";										
						var a4 = res4.findIndex((v) => {   //东财资金
						return v.f12 ===  code;
						});

						if(a4 > -1){
							var arrfind = res4.find(function (item) {
								return item.f12 == code
							});
							zlje = arrfind.f62; 
							zljzb = arrfind.f184;	
							cddje = arrfind.f66; 
							cddjzb = arrfind.f69;
						}
						res.push({"code":code,"name":name,"xianjia":xianjia,"zf":zf,"dcpm":dcpm,"rqbpm":pm1,"thspm":pm2,"rmgppm":pm3,"zlje":zlje,"zljzb":zljzb,"cddje":cddje,"cddjzb":cddjzb})					
					}
				}
				//document.write(JSON.stringify(res));
				
				for (var i = 0; i < res3.length; i++){	//以同花顺热榜为基准			
					var code = res3[i]["code"];
					var a1 = res.findIndex((v) => { 
						return v.code ===  code;
					});
					if(a1 == -1){
					//if(JSON.stringify(res).indexOf(code) == -1){
						var name = res3[i]["name"];						
						var pm2 = res3[i]["order"];
						
						var dcpm = "1000";	
						var pm1 = "1000";	
						
						var zf = 0;
						var zlje = "null";
						var zljzb = "null";
						var cddje = "null";
						var cddjzb = "null";						
						var a4 = res4.findIndex((v) => {     //东财资金
						return v.f12 ===  code;
						});
						if(a4 > -1){
							var arrfind = res4.find(function (item) {
								return item.f12 == code
							});
							zf = arrfind.f3;
							zlje = arrfind.f62; 
							zljzb = arrfind.f184;	
							cddje = arrfind.f66; 
							cddjzb = arrfind.f69;							
						}
						res.push({"code":code,"name":name,"xianjia":xianjia,"zf":zf,"dcpm":dcpm,"rqbpm":pm1,"thspm":pm2,"rmgppm":pm3,"zlje":zlje,"zljzb":zljzb,"cddje":cddje,"cddjzb":cddjzb})					
					}				
				}
				//document.write(JSON.stringify(res));
				
				arr = [];
				arr1 = [];
				arr2 = [];
				//ss = data.split('},{');						
				for (var i = 0; i < res.length; i++){
					var shy = "1000";
					var zf = res[i]["zf"];					
					var dcpm = res[i]["dcpm"];
					var rqbpm = res[i]["rqbpm"];
					var thspm = res[i]["thspm"];
					var rmgppm = res[i]["rmgppm"];
					var zlje = res[i]["zlje"];
					var zljzb = res[i]["zljzb"];
					if(dcpm <= 100 && rqbpm <= 50 && thspm <= 100 && rmgppm <= 100){
						shy = (dcpm + rqbpm  + thspm + rmgppm)/4;		
								
					}					
					var c = $.extend({},res[i], {"shy":shy});
					arr.push(c);
					
					if(shy != 1000 && zf > 0 && zlje >= 20000000 && zljzb >= 10){
						var c = $.extend({},res[i], {"shy":shy});
						arr1.push(c);
					}else{
						var c = $.extend({},res[i], {"shy":shy});
						arr2.push(c);
					}
				}
				//document.write(JSON.stringify(arr2));				
				getSource(k);
			}
			
			var k = 1;
			var gl = "";  //高亮
			var yx = 0;  //预选
			function getData() { 
				var p1 = "<a href='javascript:void(0)' id='px1' onclick='getSource(" + "1" + ")'>" + "主力净额" + "</a>";				
				var p8 = "<a href='javascript:void(0)' id='px8' onclick='getSource(" + "8" + ")'>" + "预选" + "</a>";
				var daochuimg ='<a style="margin-left: 10px;cursor: pointer;" onclick="daochu()">+导入到板块</a>'
				div1 = document.getElementById('towrite1');												
				div1.innerHTML = "<div><font size='2'><strong>综合人气榜</strong><font size='1'>&nbsp;&nbsp;&nbsp;&nbsp;（&nbsp;&nbsp;&nbsp;&nbsp;" + p1 + p8 + "）" + daochuimg + "</font></font><p></div>";
			}

			function getSource(s) {				
				// var p1 = "<a href='javascript:void(0)' id='px1' onclick='getSource(" + "1" + ")'>" + "涨幅" + "</a>";				
				// var p8 = "<a href='javascript:void(0)' id='px8' onclick='getSource(" + "8" + ")'>" + "预选" + "</a>";
				// var daochuimg ='<a style="margin-left: 10px;cursor: pointer;" onclick="daochu()">+导入到板块</a>'
				// div1 = document.getElementById('towrite');												
				// div1.innerHTML = "<div><font size='2'><strong>综合人气榜</strong><font size='1'>&nbsp;&nbsp;&nbsp;&nbsp;（&nbsp;&nbsp;&nbsp;&nbsp;" + p1 + p8 + "）" + daochuimg + "</font></font><p></div>";
				 

				if(s == 1){
					k = 1;
					gl = "主力净额";
					yx = 0;
					function up(a,b){						
						//return Number(b.zlje.toString().replace('亿',''))-Number(a.zlje.toString().replace('亿',''))				//排序			
						return b.zlje-a.zlje		
					}
					arr.sort(up);
				}else if(s == 8){
					var aObj = document.getElementById('px8');
					gl = "主力净额";					
					aObj.style.color = "#FFA07A";
					k = 8;										
					arr = [];
					if( arr1.length > 0){					
						yx = arr1.length;						
						function up1(a,b){
							return a.shy-b.shy		//人气值平均			
						}
						arr1.sort(up1);														
					}
					function up2(a,b){
						return b.zf-a.zf        //涨幅
					}
					arr2.sort(up2);
					
					arr = arr1.concat(arr2);					
				}
				
				//修改数组对象中指定的值
				//for(var i = 0;i < arr.length;i++){  //
				for(var i in arr){	
					if(arr[i].dcpm == "1000"){
						arr[i].dcpm = "无";
					}
					if(arr[i].rqbpm == "1000"){
						arr[i].rqbpm = "无";
					}
					if(arr[i].thspm == "1000"){
						arr[i].thspm = "无";
					}
					if(arr[i].rmgppm == "1000"){
						arr[i].rmgppm = "无";
					}
					if(arr[i].shy == "1000"){
						arr[i].shy = "无";
					}

					////不要转格式
					// arr[i].zlje = NumberTransform(arr[i].zlje);
					// arr[i].cddje = NumberTransform(arr[i].cddje);
				}
				//document.write(JSON.stringify(arr));
				
				
				//var json = JSON.parse(data);
				var json = arr;
				
				//创建table					
				var table=document.createElement("table");										
				var thead=document.createElement("thead");
				table.appendChild(thead);					
				var tr=document.createElement("tr");
				thead.appendChild(tr);					
				
				var m = 0;
				var n = 0;
				var b = 0;
				for(var key in json[0]){  //表头
					key = key.replace('code','代码').replace('name','名称').replace('xianjia','现价').replace('zf','涨幅%').replace('dcpm','东财').replace('rqbpm','开盘啦');
					key = key.replace('thspm','同花顺').replace('rmgppm','爱股票').replace('zlje','主力净额').replace('zljzb','主力净占比').replace('cddje','超大单净额');
					key = key.replace('cddjzb','超大单净占比').replace('shy','四合一');
					var th=document.createElement("th");						
					th.innerHTML=key;						
					tr.appendChild(th);
					if(gl == key.replace("%","")){
						n = m;
						th.style.color = "#FF6633";	
					}					
					m++;
				}
									
				var tbody=document.createElement("tbody");					
				table.appendChild(tbody);
				
				//遍历json
				daochu_codes = [];
				for(var i = 0; i < json.length; i++){					
					var tr=document.createElement("tr");						
					var p = 1;
					var dm = "";
					var mc = "";
					for(var key in json[i]){ //行元素遍历						
						var td=document.createElement("td");							
						
						var rc = json[i][key];
						if(p == 1){  //代码列
							dm = rc;
							tr.id = dm;
							daochu_codes.push(dm);	
						}			
						td.innerHTML = "<a href=http://www.treeid/code_" + dm + " id='" + p + "' onclick='changeCss(this,\"" + dm + "\",\"gg\")'>" + rc + "</a>";
						
						if(yx > 0 && i < yx){  //预选
							//tr.style.color = "#FF69B4";
							td.getElementsByTagName("a")[0].style.color = "#FF69B4";
						}
						if(p == n + 1){							
							td.getElementsByTagName("a")[0].style.color = "#FF6633";						
						}										
						tr.appendChild(td);
						p++;
					}					
					tbody.appendChild(tr);					
				}					
				var div = document.getElementById("towrite");		
				div.innerHTML = "";							
				div.appendChild(table);
				table.id = "gg";		
			
				
				var table=document.getElementsByTagName("table")[0];
				changeTable(table,"0#8#9#10#11");
				// changeTable(table,"0#2#3#4#11");
				makeSortable(table);
				hover();

			}

			//隐藏某列				
            function changeTable(table,ss) {	
				var trs = table.rows;
				ss = ss + '#';
				var aa = ss.split('#');
				for (var j = 0; j < aa.length; j++) {
					if(aa[j] != ""){
						for (var i = 0, len = trs.length; i < len; i++) {					
							var p = aa[j];
							var cell = trs[i].cells[p]; 
							cell.style.display = 'none';
						}
					}
				}					
			}

			
			
			function makeSortable(table) {
				var headers=table.getElementsByTagName("th");
				for(var i=0;i<headers.length;i++){				
					(function(n){
						var flag=false;
							
						headers[n].onclick=function(){							
							showCol(n);		//高亮

							var aObj = document.getElementById('px8');	//预选恢复原色									
							aObj.style.color = "#E5E5E5";
							
							var tbody=table.tBodies[0];
							var rows=tbody.getElementsByTagName("tr");
							rows=Array.prototype.slice.call(rows,0);

							//基于第n个<td>元素的值对行排序
							rows.sort(function(row1,row2){
								headtxt = headers[n].textContent;								
								var cell1=row1.getElementsByTagName("td")[n];//获得第n个单元格
								var cell2=row2.getElementsByTagName("td")[n];																
								var val1=cell1.textContent||cell1.innerText;//获得文本内容
								var val2=cell2.textContent||cell2.innerText;
								if(headtxt.indexOf("名称") != -1 || headtxt.indexOf("板块") != -1){
									val1 = val1;
									val2 = val2;
								}else{
									if(val1 == "-"){
										val1 = " ";
									}
									if(val2 == "-"){
										val2 = " ";
									}
									val1 = val1.replace(" ","0").replace("无","1000").replace("NaN","0");
									val2 = val2.replace(" ","0").replace("无","1000").replace("NaN","0");
									if(val1.indexOf("万") != -1){
										val1 = parseFloat(val1)*10000;
									}else if(val1.indexOf("亿") != -1){
										val1 = parseFloat(val1)*100000000;
									}else{
										val1 = parseFloat(val1);
									}
									
									if(val2.indexOf("万") != -1){
										val2 = parseFloat(val2)*10000;
									}else if(val2.indexOf("亿") != -1){
										val2 = parseFloat(val2)*100000000;
									}else{
										val2 = parseFloat(val2);
									}
								}
								if(val1<val2){
									return -1;
								}else if(val1>val2){
									return 1;
								}else{
									return 0;
								}
							});
							if(flag){
								rows.reverse();
							}
							
							for(var i=0;i<rows.length;i++){
								tbody.appendChild(rows[i]);
							}

							flag=!flag;
						}
					}(i));
				}
			}
			
			function showCol(iCol){    
				var oTable=document.getElementsByTagName('table')[0];
				for (i=0;i < oTable.rows.length; i++){										
					for (j=0;j < oTable.rows[0].cells.length; j++){
						oTable.rows[i].cells[j].style.color = "#E5E5E5";
					}
					oTable.rows[i].cells[iCol].style.color = "#FF6633";					
				}
				
				otagsA = oTable.getElementsByTagName("a");  //a变色
				for (i = 0; i < otagsA.length; i++) {
					otagsA[i].style.color = "#E5E5E5";
					if(otagsA[i].id == iCol + 1){
						otagsA[i].style.color = "#FF6633";
					}
				}							
			}
             function daochu(){

		      	if (daochu_codes.length == 0) return;
		      	var linktext="";
		        for (var i=0;i<daochu_codes.length;i++){
		            if (daochu_codes[i].charAt(0) == "6"){
		              linktext = linktext + "1#" + daochu_codes[i] + "|";
		            }else if(daochu_codes[i].charAt(0) == "8" || daochu_codes[i].charAt(0) == "9" || daochu_codes[i].charAt(0) == "4"){
		              linktext = linktext + "2#" + daochu_codes[i] + "|";
		            }else{
		              linktext = linktext + "0#" + daochu_codes[i] + "|";
		            }
		        }
				if (linktext.substr(-1) == "|") linktext = linktext.slice(0, -1); //删除末尾一位 
		        //alert(linktext);
		        window.location = "http://www.treeid/AddToBlock_"+linktext;  
			}	
		</script>		
		<script>
			var oldKey = "";
			var index = -1;
			var pos = new Array();
			var oldCount = 0;

			function gotop(){							
				$(".fixedBox").scrollTop(0);
			}
			
			function next(){			
			index++;
			//index = index == oldCount ? 0 : index;
			if(index==oldCount){
				index = 0 ;
			}
			search();
			}

			function search() {
				$(".result").removeClass("res");
				var key = $("#key").val(); 
				//alert(key);
				if (!key) {
					console.log("key为空则退出");
					$(".result").each(function () {
					$(this).replaceWith($(this).html());
					});
					oldKey = "";
					return; 
				}
				//if (oldKey != key) {
				//alert(key);
					console.log("进入重置方法");
					//重置
					$(".fixedBox").scrollTop(0);
					index = 0;
					$(".result").each(function () {
					$(this).replaceWith($(this).html());
					});
					pos = new Array();
					var regExp = new RegExp(key+'(?!([^<]+)?>)', 'ig');//正则表达式匹配
					//$("body").html($("body").html().replace(regExp, "<span id='result" + index + "' class='result'>" + key + "</span>")); // 高亮操作
					$(".fixedBox").html($(".fixedBox").html().replace(regExp, "<span id='result" + index + "' class='result'>" + key + "</span>")); // 高亮操作
					$("#key").val(key);
					oldKey = key;
					$(".result").each(function () {
					pos.push($(this).offset().top);
					});
					oldCount = $(".result").length;
					console.log("oldCount值：",oldCount);
				//}

				$(".result:eq(" + index + ")").addClass("res");
				$(".fixedBox").scrollTop(pos[index] - 100);
			}
			
		</script>		
	</body>
</html>